<?php

namespace App\Shop\Controllers;

use App\Shop\Logic\MerchantLogic;
use App\Shop\Logic\OrderLogic;
use Dingo\Api\Http\Request;

class OrderController extends BaseController
{
    public function getOrderList(Request $request)
    {
        $params = $request -> all();

        $merchant_id = MerchantLogic::getMerchantIdById($params['user_id']);

        if(!$merchant_id) {
            return $this->error('用户不存在');
        }

        $params['merchant_id'] = $merchant_id;

        $data = OrderLogic::getOrderList($params);

        return $this->success($data);
    }

    public function getOrderDetail(Request $request)
    {
        $params = $request -> all();

        $data = OrderLogic::getOrderDetail($params);

        if(!$data) {
            return $this->error(OrderLogic::getErrorMessage());
        }

        return $this->success($data);
    }
}

